package com.shuqing.download.engine.distribute;

import com.shuqing.download.engine.DefaultHandler;
import com.shuqing.download.engine.DownLoadTaskDto;
import com.shuqing.download.engine.constants.BaseConstants;
import com.shuqing.download.engine.distribute.dispatch.monitor.MonitorLeader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;

/**
 * 数据分发器
 * @author wangshuqing
 * @date 2023/2/10 11:59
 */
public interface DistributeHandler extends DefaultHandler {

    /**
    * 是否容许进入 ，并且获取任务技术
    * @date 2023/2/12 14:43
    * @author wangshuqing
    * @param
     *@return java.lang.Boolean
    * */
    Boolean accept();

    /**
    * 尽可能多的取到数据
    * @date 2023/2/16 15:15
    * @author wangshuqing
    * @param
     *@return int
    * */
    int possibleMoreAccept();

    /**
    * 分发 需要异步执行,指定线程池
    * @date 2023/2/12 14:48
    * @author wangshuqing
    * @param taskDto
    * */
    @Async(BaseConstants.THREAD_POOL_NAME)
    void process(DownLoadTaskDto taskDto);

    /**
    * 归还任务计数
    * @date 2023/2/16 15:30
    * @author wangshuqing
    * @param
    * */
    void backOneAccept();
}
